home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / Book Chapters / 10 - Networking / NovelNetwar / NovelNetwar.h < prev    next >
C/C++ Source or Header  |  1995-05-12  |  5KB  |  238 lines

  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4.  
  5. enum
  6. {
  7.     BADWINDOW = 1, TRAPABSENT, GAMENOTPLAYING, NONETNAME, NOAPPLETALK, NOTEXTEDITREC, SERIALCONNECTCANCELLED
  8. };
  9.  
  10. enum
  11. {
  12.     NONE, APPLETALK, SERIAL, MACTCP
  13. };
  14.  
  15.  
  16. #define EQSTR            0
  17.  
  18. #define VERSION        "Novel Netwar 1.0"
  19.  
  20. #define    GAMEWIND        128
  21. #define    HELPWIND        129
  22.  
  23. #define    HELPTEXT        128
  24. #define    HELPSTYL        128
  25.  
  26.  
  27. #define    INFODLOG        128
  28. #define    INPUTDLOG        129
  29. #define    TEXTDLOG        130
  30. #define INFOCANCELDLOG    131
  31. #define    OKCANCELDLOG    132
  32. #define ERRORDLOG        134
  33. #define ATALKSTARTDLOG    133
  34. #define SERIALDLOG        135
  35. #define    CHOOSEMETHODDLOG    136
  36.  
  37. #define    RETURNKEY        (char) 0x0d
  38.  
  39. #define    MAXNUMPLAYERS    6
  40. #define MAXNUMPHOTONS    3
  41.  
  42.  
  43. #define MAXDDPPACKETSIZE        586
  44.  
  45.  
  46. struct DDPDataPacket
  47. {
  48.     UInt8        destNodeID;
  49.     UInt8        srcNodeID;
  50.     UInt8        ddpHeaderType;
  51.     UInt8        datagramLengthMSB;
  52.     UInt8        datagramLengthLSB;
  53.     UInt8        destSocketNumber;
  54.     UInt8        srcSocketNumber;
  55.     UInt8        ddpProtocolType;
  56.     char        packetData[MAXDDPPACKETSIZE];
  57. };
  58. typedef struct DDPDataPacket DDPDataPacket;
  59.  
  60.  
  61.  
  62. struct GameData 
  63. {
  64.     short        x;
  65.     short        y;
  66.     short        angleIndex;
  67.     short        photonsX[MAXNUMPHOTONS];
  68.     short        photonsY[MAXNUMPHOTONS];
  69.     short        photonsTimeToLive[MAXNUMPHOTONS];
  70.     short        playerStatus;
  71. };
  72. typedef struct GameData GameData;
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80. extern    char            alive,IAmFrontApp,hasColourQD,hasAppleTalk;
  81. extern    Rect            nullRect;
  82. extern    char            errorMessage[256];
  83. extern    int                connectionMethod;
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93. // globals.c
  94.  
  95. void globalsInit(void);
  96. void globalsStartup(void);
  97. void globalsShutDown(void);
  98.  
  99.  
  100. // helpbox.c
  101.  
  102. void DoHelpBox(int helpResWIND,int helpResTEXT,int helpResSTYL);
  103.  
  104.  
  105. // windows.c
  106.  
  107. void windowsInit(void);
  108. void windowsStartup(void);
  109. void windowsShutDown(void);
  110. void DoMouseDown(EventRecord *theEvent);
  111. OSErr IsOurWindow(WindowPtr theWPtr);
  112. void DoActivateDeactivate(WindowPtr whichWindow,char adFlag);
  113. void DoCloseWindow(WindowPtr whichWindow);
  114. void DoGrow(WindowPtr whichWindow,EventRecord *theEvent);
  115. void DoZoom(WindowPtr whichWindow,int windowCode);
  116. void DoDrag(WindowPtr whichWindow,EventRecord *theEvent);
  117. void DoContent(WindowPtr whichWindow,EventRecord *theEvent);
  118. void UpdateWindow(WindowPtr whichWindow);
  119. void doUpdate(CWindowPtr window);
  120.  
  121.  
  122. // dialogs.c
  123.  
  124. OSErr GetInput(char    *thePrompt,char *theText);
  125. OSErr YesNoDialog(char    *thePrompt,int    theDefault);
  126. void FatalError(char *fatalString);
  127. void ErrorAlert(char *p0);
  128. OSErr ProcessDialogCmdKey(DialogPtr theDialog,EventRecord *theEvent,short *itemHit);
  129. pascal Boolean MyFilter(DialogPtr theDialog,EventRecord *theEvent,short *itemHit);
  130. void CenterWindow(WindowPtr wPtr);
  131. pascal void HiliteDefaultButton(DialogPtr theDPtr,int whichItem);
  132.  
  133.  
  134. // misc.c
  135.  
  136. OSErr BreakKey(void);
  137. OSErr OptionKey(void);
  138. OSErr CtrlKey(void);
  139. OSErr ShiftKey(void);
  140. OSErr CommandKey(void);
  141. OSErr CapsLock(void);
  142. void getGrayRgnRect(Rect *theRect);
  143. void mystrncpy(register char *s1, register char *s2,register long n);
  144. void mystrncat(register char *s1, register char *s2,register long n);
  145. OSErr TrapAvailable(int theTrap);
  146.  
  147.  
  148. // menus.c
  149.  
  150. void menusInit(void);
  151. void menusStartup(void);
  152. void menusShutDown(void);
  153. OSErr DoCommand(long mResult);
  154. void MarkReinforcementsMenu(void);
  155. void DisableEditMenu(void);
  156. void EnableEditMenu(void);
  157.  
  158.  
  159. // helpbox.c
  160.  
  161. void helpInit(void);
  162. void helpStartup(void);
  163. void helpShutDown(void);
  164. void DoHelpBox(int helpResWIND,int helpResTEXT,int helpResSTYL);
  165. void helpCloseWindow(WindowPtr whichWindow);
  166. void helpGrowWindow(WindowPtr whichWindow,EventRecord *theEvent);
  167. void helpDragWindow(WindowPtr whichWindow,EventRecord *theEvent);
  168. void helpActivateWindow(WindowPtr whichWindow,char adFlag);
  169. OSErr helpIsWindow(WindowPtr theWPtr);
  170. void helpUpdateWindow(WindowPtr theWPtr);
  171. void helpDoContent(WindowPtr whichWindow,EventRecord *theEvent);
  172.  
  173.  
  174.  
  175. // main.c
  176.  
  177. void terminate(void);
  178. void DoShutDown(void);
  179. void mainDoIdle(void);
  180.  
  181.  
  182. // myabout.c
  183.  
  184. void DoAboutBox(int doWait);
  185.  
  186.  
  187.  
  188. // cursors.c
  189.  
  190. void cursorsInit(void);
  191. void cursorsStartup(void);
  192. void cursorsShutDown(void);
  193. void cursorsMaintainCursor(Point theMousePt);
  194. void cursorReactToMouseClick(Point theMousePt);
  195.  
  196.  
  197. // appleEvents.c
  198.  
  199. void appleEventsInit(void);
  200. void appleEventsStartup(void);
  201. void appleEventsShutDown(void);
  202. void DoHighLevel(EventRecord *theEvent);
  203.  
  204.  
  205.  
  206.  
  207. // gameplay.c
  208.  
  209. void gameplayInit(void);
  210. void gameplayStartup(void);
  211. void gameplayShutdown(void);
  212. void gameplayDoContent(WindowPtr theWPtr,EventRecord *theEvent);
  213. OSErr gameplayIsWindow(WindowPtr theWPtr);
  214. void gameplayUpdateWindow(WindowPtr theWPtr);
  215. void gameplayDragWindow(WindowPtr theWPtr,EventRecord *theEvent);
  216. void gameplayActivateWindow(WindowPtr theWPtr,char adFlag);
  217. void gameplayIdle(void);
  218. void gameReceiveBroadcastData(Ptr theBroadcastData,long theBroadcastDataLength);
  219. void gameplayHandleBroadcastCompletion(void);
  220.  
  221. // appletalking.c
  222.  
  223. void appletalkingInit(void);
  224. void appletalkingStartup(void);
  225. void appletalkingShutdown(void);
  226. OSErr appleTalkingConnectToOpponents(void);
  227. void appleTalkingSendData(Ptr theDataPtr,long theDataLength);
  228.  
  229.  
  230. // serial.c
  231.  
  232.  
  233. void serialInit(void);
  234. void serialStartup(void);
  235. void serialShutdown(void);
  236. OSErr serialConnectToOpponents(void);
  237. void serialSendData(Ptr theDataPtr,long theDataLength);
  238.